<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Migrations\Migration;

return new class extends Migration {
    
    protected $connection = "default";

    public function up(): void
    {
        \support\Db::schema()->create('admin',function (Blueprint $table){
            $table->increments('id');

            $table->string("username",64)->nullable(false)->comment("用户名");
            $table->string("nickname",64)->comment("昵称");
            $table->string("realname",64)->comment("真实姓名");
            $table->string("password",64)->comment("密码");
            $table->string("avatar")->comment("头像");
            $table->string("email",64)->comment("邮箱");
            $table->tinyInteger("state")->default(1)->comment("状态,1正常,0冻结");

            $table->timestamps();

            $table->comment("系统管理员表");
        });

        \support\Db::schema()->create('admin_logs',function (Blueprint $table){
            $table->increments('id');
            $table->integer("admin_id")->unsigned()->comment("管理员id");
            $table->tinyInteger("method")->comment("操作方法：POST,PUT,DELETE");
            $table->string("url")->nullable()->comment("请求地址");
            $table->text("params")->comment("请求参数");
            $table->text("result")->comment("响应数据");
            $table->timestamps();
        });

        \support\Db::schema()->create('admin_upload',function (Blueprint $table){
            $table->increments('id');
            $table->integer("admin_id")->unsigned()->comment("管理员id");
            $table->string("name")->comment("文件名");
            $table->string("type")->comment("文件类型");
            $table->integer("size")->default(0)->comment("文件大小");
            $table->string("path")->comment("保存路径");
            $table->timestamps();
        });
    }

    public function down(): void
    {
        \support\Db::schema()->dropIfExists('admin');
        \support\Db::schema()->dropIfExists('admin_logs');
        \support\Db::schema()->dropIfExists('admin_upload');
    }

};